﻿<!DOCTYPE html>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="UTF-8" />
    <title>Aperture-Test</title>
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
</head>
<body>
    <h3>Test</h3>

    <input type="button" onclick="addClickEvents();" value="lol" /><br />

    <object id="sv" data="0001_GB01_OG14_0000_Aperture.svg" type="image/svg+xml">
        <!-- <img src="yourfallback.jpg" alt="SVG fallback image" /> -->
    </object>

    <script type="text/javascript">

        // console.log(SD);

        // var circle1 = SD.getElementById("GR");

        console.log("test");



        function getCenter()
        {
            var el = document.querySelector("path");
            var bbox = el.getBoundingClientRect();
            var center = {
                x: bbox.left + bbox.width / 2,
                y: bbox.top + bbox.height / 2
            };

            return center;
        }

        function showEntity(e)
        {
            console.log("showEntity");
            var node = e.target;
            console.log(node);

            /*
			if (node.id != 'ocean') {
				node = getCorrectNode(node);
			}

			alert(node.id);
			*/
        }



        function addClickEvents()
        {
            var S = document.getElementById("sv")
            // console.log(S);

            var SD = S.getSVGDocument();
            // console.log(SD);


            var layers = SD.rootElement.getElementsByTagName("g");

            for (var i = layers.length -1; i > -1; --i)
            {
                //if ("FM_OBJEKT_RAUM" != layers[i].id)
                if (true)
                {
                    /*
                    while (layers[i].firstChild)
                    {
                        layers[i].removeChild(layers[i].firstChild);
                    }
                    */
                    // console.log(layers[i].ownerSVGElement);
                    layers[i].ownerSVGElement.removeChild(layers[i]);
                    // SD.rootElement.removeChild(layers[i]);
                    // layers[i].parentNode.removeChild(layers[i]);
                }

                //console.log(layers[i].id);
            }


            // S.contentDocument.
            SD.addEventListener('click', showEntity);
            /*
			var countries = document.getElementById('svg1926').childNodes;
			var i;
			for (i=0;i<countries.length;i++){
				countries[i].addEventListener('click', showCountry);
			}
			*/
        }

        // addClickEvents();


    </script>

</body>
</html>
